Skip to content

Conversation

@nnethercote
Copy link
Contributor

Some cleanups in and around the canonicalizers, found while I was looking closely at this code.

r? @lcnr

@rustbot
Copy link
Collaborator

rustbot commented Jan 7, 2026

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jan 7, 2026
@nnethercote nnethercote force-pushed the canonicalizer-cleanups branch from 2c8e55e to a24aef0 Compare January 7, 2026 06:27
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the canonicalizer-cleanups branch from a24aef0 to d0278f9 Compare January 7, 2026 07:19
@lcnr
Copy link
Contributor

lcnr commented Jan 7, 2026

@bors try @rust-timer queue

r=me after perf, I assume that u measured it to not have an impact, but want to be sure

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 7, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 7, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 7, 2026

☀️ Try build successful (CI)
Build commit: 23ed3e9 (23ed3e95ddb50d9de56e5fba78af875e824ef8d7, parent: d9617c8d9a55773a96b61ba3a4acb107d65615c1)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (23ed3e9): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.5%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.7%, secondary -0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.7% [2.3%, 3.3%] 3
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) 2.7% [2.3%, 3.3%] 3

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.542s -> 471.79s (-0.58%)
Artifact size: 390.84 MiB -> 390.85 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 7, 2026
It's an empty `Vec` at both call sites, and so is unnecessary.
Variables that are collections of `CanonicalVarKind` are sometimes
called `var_kinds` and sometimes called `variables`. The former is much
better, because `variables` is (a) non-descript, and (b) often used
nearby for collections of `I::GenericArg`. I found the inconsistency
made the canonicalization code harder to understand.

This commit renames various `variables` things as `var_kinds`.
Currently it's a mutable reference, but it doesn't need to be, because
what's passed in is always a mutable reference to an empty `Vec`. This
requires returning variables in a few extra places, which is fine. It
makes the handling of `variables` the same as the handling of
`var_kinds` and `variable_lookup_table`.
It's weird. `clone` is better.
I did some measurements. The current choice of 16 is fine.
This explains why the predicate folding code looks different to the
ty/const folding code, something I was wondering.
@nnethercote nnethercote force-pushed the canonicalizer-cleanups branch from d0278f9 to b222cf3 Compare January 8, 2026 04:04
@nnethercote
Copy link
Contributor Author

The slight regressions on the new-solver benchmarks are due to the "Make Canonicalizer::variables owned" commit. Let's try a possible fix:

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jan 8, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

☀️ Try build successful (CI)
Build commit: 0a07a16 (0a07a161046bb0312b7c8ec7d9794b1fc0628e02, parent: 548e586795f6b6fe089d8329aa5edbf0f5202646)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0a07a16): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.5%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.1% [-2.1%, -2.1%] 1

Cycles

Results (primary 2.4%, secondary -4.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.9% [-4.9%, -4.9%] 1
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.664s -> 473.643s (-0.22%)
Artifact size: 390.87 MiB -> 390.87 MiB (-0.00%)

@rustbot rustbot removed perf-regression Performance regression. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 8, 2026
@nnethercote
Copy link
Contributor Author

The final commit fixes the problem. I don't understand why, even though I spent a chunk of today investigating it. I can't work out why cloning a Vec would cause more allocations than extending an empty Vec.

@lcnr
Copy link
Contributor

lcnr commented Jan 8, 2026

@bors r+ rollup=never

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

📌 Commit b222cf3 has been approved by lcnr

It is now in the queue for this repository.

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added the merged-by-bors This PR was explicitly merged by bors. label Jan 12, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 12, 2026

☀️ Test successful - CI
Approved by: lcnr
Pushing 44a5b55 to main...

@rust-bors rust-bors bot merged commit 44a5b55 into rust-lang:main Jan 12, 2026
13 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 12, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b68e16c (parent) -> 44a5b55 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 44a5b55557c26353f388400d7da95527256fe260 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-llvm-mingw: 5365.4s -> 6419.2s (+19.6%)
  2. pr-check-1: 1676.0s -> 1943.5s (+16.0%)
  3. test-various: 6458.2s -> 7459.5s (+15.5%)
  4. aarch64-gnu-debug: 3777.5s -> 4359.1s (+15.4%)
  5. i686-gnu-2: 5068.8s -> 5838.8s (+15.2%)
  6. aarch64-apple: 8437.9s -> 9661.2s (+14.5%)
  7. dist-apple-various: 4167.0s -> 3619.8s (-13.1%)
  8. aarch64-gnu-llvm-20-2: 2709.3s -> 3041.7s (+12.3%)
  9. x86_64-gnu-llvm-20-1: 4128.7s -> 4623.7s (+12.0%)
  10. x86_64-gnu-gcc: 3124.2s -> 3490.7s (+11.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (44a5b55): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary -3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-4.3%, -2.7%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 473.667s -> 473.154s (-0.11%)
Artifact size: 391.39 MiB -> 391.41 MiB (0.01%)

@nnethercote nnethercote deleted the canonicalizer-cleanups branch January 13, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants